Script loading
To use external javascript dependencies, you can load them from a CDN, such as:
Just like when writing a browser app, there are two ways to import JS dependencies: a <script>
tag, and the more modern ES6 import.
Loading method 1: ES6 imports
we recommend that you use an ES6 import if the library supports it.
Awkward note about syntax
Normally, you can import libraries inside JS using the import syntax:
import confetti from 'https://cdn.skypack.dev/canvas-confetti'
import { html, render, useEffect } from "https://cdn.jsdelivr.net/npm/htm@3.0.4/preact/standalone.mjs"
In Pluto, this is currently not yet supported, and you need to use a different syntax as workaround:
const { default: confetti } = await import("https://cdn.skypack.dev/canvas-confetti@1")
const { html, render, useEffect } = await import( "https://cdn.jsdelivr.net/npm/htm@3.0.4/preact/standalone.mjs")